package com.itheima.utils;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.aspectj.lang.annotation.Before;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * C3P0
 */
@Component
public class C3P0Util {

    private static ComboPooledDataSource ds = new ComboPooledDataSource();

    @Bean
    public static DataSource getDataSource() {
        return ds;
    }

    @Bean
    public static Connection getConnection() throws SQLException {
        return ds.getConnection();
    }

    public static void main(String[] args) {
        System.out.println(getDataSource());
    }
}
